$(function () {
	//登录
	var url = "/data/register.php";
	$('button').click(function () {
	   var name = $('#name').val();
	   var password = $('#password').val();


     if(name.trim() == "" || password.trim() == ""){
        if(name.trim() == ""){
            layer.tips('用户名不能为空', '#name', {tips:1, time:2000});
        }else if(password.trim() == ""){
            layer.tips('密码不能为空', '#password', {tips:1, time:2000});
        }

        return;
     }
  
	   $.ajax({
	   	    url:url,
          type:'post',
          data:{
              username: name,
              password:password
          },
          dataType:'json',
          success:function(data){
              //localStorage.setItem('mid',data.result.menber_id);
              if(data.errno == "0000"){
                setTimeout(function(){
                    location.href = "login.html";
                },1000);
              }else{
                layer.msg(data.errmsg, {time: 2000});
              }
          },
          error:function(){
              layer.msg("网络错误请重试！");
          }
	   });
	});
});